<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Article_model extends WST_Model {
	private $_table = "articles";

	function __contruct(){
        parent::__construct();
    }

    function count_all(){
        $this->db->where('status',1);
        return $this->db->count_all_results($this->_table);
    }
    function find_all($current_page = 1, $page_size = 30){

        $where =" WHERE status=1";
        $sql = "select * from ".$this->_table. $where."   order by id ASC";
        if ($current_page > 0 && $page_size > 0) {
            $offset = ($current_page-1)* $page_size;
            $sql .= " limit {$offset}, {$page_size}";
        }
        $query = $this->db->query($sql);
        $data = $query->result_array();
        $query->free_result();
        return $data;
    }
}